<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="/pages/login/common.jsp" %>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.店铺宣传信息申请</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/demo.css">
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />

<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.excheck-3.4.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.shop.application.js"></script>

	<link rel="stylesheet" href="<%=path%>/include/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="<%=path %>/include/layui/lay/dest/layui.all.js" charset="utf-8"></script>

<style type="text/css">
body{}
table{border-collapse: collapse;}
tr{ 
    display:block; /*将tr设置为块体元素*/ 
    margin:10px;  /*设置tr间距为2px*/ 
    width:100%;
}
td{padding:5px;height:30px; line-height:30px;}
.td1{
	width:100px;
	font-size:14px;
	text-align:right;
	vertical-align: middle;
}
.input1{
	width:300px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
	float:left;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
.promptBox{display:inline-block;height:30px;padding-left:5px;width:200px;white-space:nowrap; z-index:50; position:relative;}
.tips-errow{background-position:-296px -22px;color:#f52c2c;}
.tips-ok{background-position:-296px 14px;color:#666;}
.tipsCur{background-position:-296px -55px;color:#666;}
.approveDiv{width:100%;height:23px;margin:0 20px;;padding:15px 0 10px 0;border-bottom: 1px solid #ADADAD;color:blue;}
</style>
<script type="text/javascript">

function _checkAllReady(){
	var result = true;
	jQuery(".rightTd input").each(function(index){
		if(jQuery(this).val()=="" && (jQuery(this).attr("name")=="citySel" || jQuery(this).attr("name")=="shopArea") ){
			result = false;
			jQuery(this).nextAll("div").find(".tips-ok").hide();
			jQuery(this).nextAll("div").find(".tips-errow").hide();
			jQuery(this).nextAll("div").find(".tipsCur").show();
		}
		if(this.name!='file'){
			if(jQuery(this).val()=="" && jQuery(this).attr("name")!="idcardF" 
					&& jQuery(this).attr("name")!="idcardB" && jQuery(this).attr("name")!="businessLicense"){
				result = false;
				jQuery(this).next("div").find(".tips-ok").hide();
				jQuery(this).next("div").find(".tips-errow").hide();
				jQuery(this).next("div").find(".tipsCur").show();
			}else if(jQuery(this).val()=="" && jQuery(this).attr("name")!="idcardF" 
					&& jQuery(this).attr("name")!="idcardB" && jQuery(this).attr("name")!="businessLicense"){
				console.log(33);
				result = false;
				jQuery(this).parent().nextAll().find(".tips-ok").hide();
				jQuery(this).parent().nextAll().find(".tips-errow").hide();
				jQuery(this).parent().nextAll().find(".tipsCur").show();
			}
		}
	});
	jQuery(".rightTd textarea").each(function(index){
		if(jQuery(this).val()==""){
			result = false;
			jQuery(this).next("div").find(".tips-ok").hide();
			jQuery(this).next("div").find(".tips-errow").hide();
			jQuery(this).next("div").find(".tipsCur").show();
		}
	});
	jQuery(".rightTd select").each(function(index){
		if(jQuery(this).val()==""){
			result = false;
			jQuery(this).nextAll("div").find(".tips-ok").hide();
			jQuery(this).nextAll("div").find(".tips-errow").hide();
			jQuery(this).nextAll("div").find(".tipsCur").show();
		}
	});
	return result;
}
	
	//保存宣传信息
	function applyHomeDisplay(){
		var APPLICATION_UUID=$("#APPLICATION_UUID").val();
		if(_checkAllReady() && APPLICATION_UUID==""){//初次申请
			parent.swal({
                        title: "店铺宣传申请",
                        text: "确认提交申请信息吗？",
                        type: "info",
                        showConfirmButton:true,  
                        showCancelButton: true,
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        animation: "slide-from-top",
                    }, function(inputValue) {
                    	if(inputValue){
                    			$.ajax({
									url:"<%=path%>/shopManage/applyHomeDisplay.do",
									data:{"homeApplicationBean.APPLICATION_NAME":$("#APPLICATION_NAME").val(),
				  					"homeApplicationBean.APPLICATION_CONTENT":$("#APPLICATION_CONTENT").val(),
				  					"homeApplicationBean.APPLICATION_PIC":$("#APPLICATION_PIC").val(),
				 					"homeApplicationBean.BEG_TIME_STRING":$("#BEG_TIME_STRING").val(),
				  					"homeApplicationBean.END_TIME_STRING":$("#END_TIME_STRING").val()
				  					},
									type:"post",
									success:function(result){
										if (result.success == undefined) {
											result = eval('(' + result + ')');
										}
                						if(result.success){
                    						parent.swal("保存信息成功!");
                						}
               							window.location.reload();
									}
								});
                    	}
                    });
			
		}else if(_checkAllReady() && APPLICATION_UUID!=""){//修改
			parent.swal({
                        title: "店铺宣传申请",
                        text: "确认修改宣传信息吗？",
                        type: "info",
                        showConfirmButton:true,  
                        showCancelButton: true,
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        animation: "slide-from-top",
                    }, function(inputValue) {
                    	if(inputValue){
                    			$.ajax({
									url:"<%=path%>/shopManage/upDateApplyHomeDisplay.do",
									data:{"homeApplicationBean.APPLICATION_NAME":$("#APPLICATION_NAME").val(),
				  					"homeApplicationBean.APPLICATION_CONTENT":$("#APPLICATION_CONTENT").val(),
				  					"homeApplicationBean.APPLICATION_PIC":$("#APPLICATION_PIC").val(),
				 					"homeApplicationBean.BEG_TIME_STRING":$("#BEG_TIME_STRING").val(),
				  					"homeApplicationBean.END_TIME_STRING":$("#END_TIME_STRING").val(),
				  					"homeApplicationBean.APPLICATION_UUID":$("#APPLICATION_UUID").val()
				  					},
									type:"post",
									success:function(result){
										if (result.success == undefined) {
											result = eval('(' + result + ')');
										}
                						if(result.success){
                    						parent.swal("申请成功!");
                						}
               							window.location.reload();
									}
								});
                    	}
                    });
		}
		
	}
	
	//返回店铺信息
	function returnShopInfo(){
		window.location.href="<%=path%>/shopManage/toShopInfo.do";
	
	}
	
	//再次申请
	function applyAgain(){
		parent.swal({
                        title: "店铺宣传申请",
                        text: "确认提交信息吗？",
                        type: "info",
                        showConfirmButton:true,  
                        showCancelButton: true,
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        animation: "slide-from-top",
                    }, function(inputValue) {
                    	if(inputValue){
                    			$.ajax({
									url:"<%=path%>/shopManage/applyAgain.do",
									data:{"homeApplicationBean.APPLICATION_NAME":$("#APPLICATION_NAME").val(),
				  					"homeApplicationBean.APPLICATION_CONTENT":$("#APPLICATION_CONTENT").val(),
				  					"homeApplicationBean.APPLICATION_PIC":$("#APPLICATION_PIC").val(),
				 					"homeApplicationBean.BEG_TIME_STRING":$("#BEG_TIME_STRING").val(),
				  					"homeApplicationBean.END_TIME_STRING":$("#END_TIME_STRING").val(),
				  					"homeApplicationBean.APPLICATION_UUID":$("#APPLICATION_UUID").val()
				  					},
									type:"post",
									success:function(result){
										if (result.success == undefined) {
											result = eval('(' + result + ')');
										}
                						if(result.success){
                    						parent.swal("申请成功!");
                						}
               							window.location.reload();
									}
								});
                    	}
                    });
	}
	
</script>
</head>
<body class="theme-red" data-theme="theme-red" style="height: 70%">
	<div id="contentDiv" style="width:99%;padding:4px;" >
		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
			<div class="toptil">店铺宣传信息申请</div>
		</div>
		<form id="fm" name="fm" class="form-horizontal form-validate" method="post" action="" novalidate="novalidate">
			<input type="hidden" id="shopId" name="shopId" value="${shopMap.SHOP_ID }">
			<input type="hidden" id="APPLICATION_UUID" name="homeApplicationBean.APPLICATION_UUID" value="${homeApplicationBean.APPLICATION_UUID }">
			<input type="hidden" id="curPath" name="curPath" value="<%=path %>">
			<div style="width:100%;margin-top:20px;margin-left:10px;">
				<table style="width:100%;">
					<tr>
						<td class="td1"  nowrap>宣传名称：</td>
						<td class="rightTd" nowrap>
							<input type="text" class="input1" id="APPLICATION_NAME" name="homeApplicationBean.APPLICATION_NAME" value="${homeApplicationBean.APPLICATION_NAME}" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入宣传名称</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入宣传名称</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>宣传内容：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="APPLICATION_CONTENT" name="homeApplicationBean.APPLICATION_CONTENT" value="${homeApplicationBean.APPLICATION_CONTENT }" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入宣传内容</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入宣传内容</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">宣传图片：</td>
						<td class="rightTd" nowrap>
							<div id="applicationPicDiv" style="float:left;text-align:center;">
								<div id="imgDiv3" style="margin-bottom:10px;">
									<img src="${homeApplicationBean.APPLICATION_PIC }"
										id="imgView3" style="height: 120px; width: 300px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="test">
								</div>
							</div>
							<input id="APPLICATION_PIC" name="homeApplicationBean.APPLICATION_PIC" type="hidden" value="${homeApplicationBean.APPLICATION_PIC }" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请上传宣传图片</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请上传宣传图片</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">开始时间：</td>
						<td class="rightTd" nowrap>
							<input type="text" id="BEG_TIME_STRING" name="homeApplicationBean.BEG_TIME_STRING" 
							    	style="width:200px;height:30px;line-height:30px;vertical-align:middle;float:left;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',position:{left:134.5,top:114}})" class="Wdate" value="${homeApplicationBean.BEG_TIME_STRING }" />
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入开始时间</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入开始时间</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">结束时间：</td>
						<td class="rightTd" nowrap>
							<input type="text" id="END_TIME_STRING" name="homeApplicationBean.END_TIME_STRING" 
							    	style="width:200px;height:30px;line-height:30px;vertical-align:middle;float:left;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'BEG_TIME_STRING\')}',position:{left:134.5,top:174}})" class="Wdate" value="${homeApplicationBean.END_TIME_STRING }"/>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入结束时间</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入结束时间</div>
		                   	</div>	
						</td>
					</tr>
					<c:if test="${!empty homeApplicationBean.APPLICATION_STATUS}">
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">审核状态：</td>
						<td class="rightTd" nowrap>
							<c:if test="${homeApplicationBean.APPLICATION_STATUS==0}">待审核</c:if>
							<c:if test="${homeApplicationBean.APPLICATION_STATUS==1}">审核通过</c:if>
							<c:if test="${homeApplicationBean.APPLICATION_STATUS==2}">审核未通过</c:if>
						</td>
					</tr>
					</c:if>
					<tr>
						<td class="td1">&nbsp;</td>
						<td style="">
							<!-- <div id="btnDiv" style="float: left;padding-left: 15px;"> -->
								<c:if test="${empty homeApplicationBean.APPLICATION_STATUS}">
								    <button  type="button" onclick="applyHomeDisplay();">申请</button>
									<!-- <a onclick="applyHomeDisplay();" class="btn btn-primary" style="text-decoration:none;">申请</a> -->
								</c:if>
								<c:if test="${homeApplicationBean.APPLICATION_STATUS==0}">
								    <button  type="button" onclick="applyHomeDisplay();">保存</button>
									<!-- <a onclick="applyHomeDisplay();" class="btn btn-primary" style="text-decoration:none;">保存</a> -->
								</c:if>
								<c:if test="${homeApplicationBean.APPLICATION_STATUS==2}">
								    <button  type="button" style="width:66px;background-size:180px 458px; " onclick="returnShopInfo();">再次申请</button>
									<!-- <a onclick="applyAgain();" class="btn btn-primary" style="text-decoration:none;">再次申请</a> -->
								</c:if>
							    <button  type="button" style="width:88px;background-size:240px 458px; " onclick="returnShopInfo();">返回店铺信息</button>
							<!-- </div>
							<div id="btnDiv" style="float: left;padding-left: 15px;">
								<a onclick="returnShopInfo();" class="btn btn-primary" style="text-decoration:none;">返回店铺信息</a>
							</div> -->
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
 <script type="text/javascript">
layui.use('upload', function(){
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,success: function(res){
			
			$("#APPLICATION_PIC").val(res.url);
			$("#imgView3").attr("src", res.url);
			if($.trim($("#shopPic").val()) != ''){
				$("#applicationPicDiv").nextAll('div').find(".tips-errow").hide();
				$("#applicationPicDiv").nextAll('div').find(".tipsCur").hide();
				$("#applicationPicDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
});
</script>
</html>
